﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApplication35
{
    class Program
    {
        static void CarDrivingByTrafficColor(Car car, LightColor lightColor)
        {
            switch (lightColor)
            {
                case LightColor.Red:
                    car.Stop();
                    break;
                case LightColor.Yellow:
                    car.GoSlowly();
                    break;
                case LightColor.Green:
                    car.Go();
                    break;
                default:
                    //do nothing
                    break;
            }
        }

        static void Main(string[] args)
        {
            LightColor startColor = LightColor.Green;

            TrafficLight trafficLight = new TrafficLight(startColor, 20, 5, 20);

            Car car = new Car();
            CarDrivingByTrafficColor(car, startColor);

            trafficLight.LightColorChanged += (sender, e) =>
            {
                CarDrivingByTrafficColor(car, e.CurrentColor);
            };

            Console.ReadLine();
        }
    }
}
